<template>
  <div>
    <SearchCard ref="searchCard" :model="search">
      <template #roleName>
        <el-form-item label="角色名称" prop="roleName">
          <el-input v-model="search.roleName" clearable placeholder="请输入角色名称"></el-input>
        </el-form-item>
      </template>
      <template #roleCode>
        <el-form-item label="角色标识" prop="roleCode">
          <el-input v-model="search.roleCode" clearable placeholder="请输入角色标识"></el-input>
        </el-form-item>
      </template>
      <template #status>
        <el-form-item label="状态" prop="status">
          <el-select v-model="search.isEnable" clearable placeholder="请选择">
            <el-option label="正常" :value="1"></el-option>
            <el-option label="停用" :value="0"></el-option>
          </el-select>
        </el-form-item>
      </template>
      <template #createTime>
        <el-form-item label="创建时间" prop="createTime">
          <el-date-picker
            v-model="search.createTime"
            type="daterange"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
      </template>
      <template #btnGroup>
        <el-button type="primary" @click="handleSearch">
          <el-icon>
            <Search />
          </el-icon>
          搜索
        </el-button>
        <el-button @click="handleReset">
          <el-icon>
            <RefreshRight />
          </el-icon>
          重置
        </el-button>
      </template>
    </SearchCard>
  </div>
</template>

<script setup lang="ts">
import { Role } from "@/api/interface";
import SearchCard from "@/components/SearchCard/index.vue";
import { FormInstance } from "element-plus";
import { useSearchConfig } from "@/hooks/useTable";
import { TSearchEvent } from "@/typings/global";

defineOptions({
  name: "SearchFrom"
});

const props = defineProps<{ searchEvent: TSearchEvent<Role.IRoleParams> }>();

const searchCard = ref<FormInstance>();

const { search, handleSearch, handleReset } = useSearchConfig<Role.IRoleParams>(
  {
    roleName: "",
    roleCode: "",
    isEnable: "",
    createTime: []
  },
  props,
  searchCard
);
</script>
<style></style>
